﻿#region Namespaces

using System;
using System.Collections;
using System.Collections.Generic;

using Vibstudio.X4NET.Csv;
using Vibstudio.X4NET.Globalization;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Vibstudio.X4NET.Test
{
    [TestClass]
    public class GlobalizationTests
    {
        [TestMethod]
        public void LabelerFactoryTest()
        {
            Labeling<ILabeling, Labeler> factory = Labeling.Factory;

            factory.Get.AppLang = "it";
            string minuts = factory.Get["Minutes"];
            Assert.AreEqual("Minuti", minuts);

            factory.Get.AppLang = "en";
            string hours = Labeling.Factory.Get["Hours"];
            Assert.AreEqual("Hours", hours);

            try
            {
                throw new CsvFormatException();
            }
            catch (Exception exception)
            {
                Assert.AreEqual("CSV is malformed.", exception.Message);
            }

            factory.Get.AppLang = "it";
            try
            {
                throw new CsvFormatException();
            }
            catch (Exception exception)
            {
                Assert.AreEqual("Il CSV è malformato.", exception.Message);
            }
        }

        [TestMethod]
        public void INILabelingProvider_LabelTest()
        {
            ILabelingProvider provider = new TestINILabelingProvider();

            string actual = provider["Hours", "it"];

            Assert.AreEqual("Ore", actual);
        }

        [TestMethod]
        public void INILabelingProvider_DictionaryTest()
        {
            ILabelingProvider provider = new TestINILabelingProvider();

            IList<DictionaryEntry> actual = provider.LabelDictionary();

            Assert.Inconclusive("Test OK");
        }

        [TestMethod]
        public void JsonLabelingProvider_LabelTest_1()
        {
            ILabelingProvider provider = new TestJsonLabelingProvider();

            string actual = provider["Hours", "ita"];

            Assert.AreEqual("Ore", actual);
        }

        [TestMethod]
        public void JsonLabelingProvider_LabelTest_2()
        {
            ILabelingProvider provider = new TestJsonLabelingProvider();

            string actual = provider["Hours", "ITA"];

            Assert.AreEqual("Ore", actual);
        }

        [TestMethod]
        public void JsonLabelingProvider_DictionaryTest_1()
        {
            ILabelingProvider provider = new TestJsonLabelingProvider();

            IList<DictionaryEntry> actual = provider.LabelDictionary();

            Assert.Inconclusive("Test OK");
        }

        [TestMethod]
        public void JsonLabelingProvider_DictionaryTest_2()
        {
            ILabelingProvider provider = new TestJsonLabelingProvider();

            IList<DictionaryEntry> actual = provider.LabelDictionary("ita");

            Assert.Inconclusive("Test OK");
        }

        [TestMethod]
        public void JsonLabelingProvider_DictionaryTest_3()
        {
            ILabelingProvider provider = new TestJsonLabelingProvider();

            IList<DictionaryEntry> actual = provider.LabelDictionary("ITA");

            Assert.Inconclusive("Test OK");
        }

        class TestINILabelingProvider : INILabelingProvider
        {
            public TestINILabelingProvider(string lang = "", string langFileName = "", string appLangKey = "")
                : base(lang, langFileName, appLangKey)
            {
            }
        }

        class TestJsonLabelingProvider : JsonLabelingProvider
        {
            public TestJsonLabelingProvider(string lang = "", string langFileName = "", string appLangKey = "")
                : base(lang, langFileName, appLangKey)
            {
            }
        }
    }
}